import logging
from utils.path_generator import filePath

fmt='%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'
logger = logging.getLogger()
format_str = logging.Formatter(fmt)  # 设置日志格式
logger.setLevel(logging.INFO)  # 设置日志级别
sh = logging.StreamHandler()  # 往屏幕上输出
sh.setFormatter(format_str)  # 设置屏幕上显示的格式
th=logging.FileHandler(filePath.logPath+"testlog.txt",mode='w', encoding='utf-8')
th.setFormatter(format_str)  # 设置文件里写入的格式
logger.addHandler(sh)  # 把对象加到logger里
logger.addHandler(th)